<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
</head>
<body>
<h1>JavaScript 验证输入</h1>

<p>请输入 1 到 10 之间的数字：</p>

<input id="numb">

<button type="button" onclick="myFunction()">提交</button>

<p id="demo"></p>

<script>
  function myFunction() {
    var x, text;

    // 获取 id="numb" 的值
    x = document.getElementById("numb").value;

    // 如果输入的值 x 不是数字或者小于 1 或者大于 10，则提示错误 Not a Number or less than one or greater than 10
    if (isNaN(x) || x < 1 || x > 10) {
      text = "输入错误";
    } else {
      text = "输入正确";
    }
    document.getElementById("demo").innerHTML = text;
  }
</script>
<p>搜索字符串 "w3cSchool", 并显示匹配的起始位置：</p>
<button onclick="myFunction()">点我</button>
<p id="a"></p>
<script>
  function myFunction() {
    var str = "Visit W3cSchool!";
    var n = str.search(/w3cSchool/i);
    document.getElementById("a").innerHTML = n;
  }
</script>
<script>
  var d=new Date();
  document.write(d);
</script>
<p id="b">单击按钮显示1970年1月1号至今的毫秒数。</p>
<button onclick="myFunction()">点我</button>
<script>
  function myFunction(){
    var d = new Date();
    var x = document.getElementById("b");
    x.innerHTML=d.getTime();
  }
</script>

</body>
</html>